<template>
	<view>
		<view class="service_list">
			<view class="service_item" v-for="item in serviceList" :key="item.id" @click="toDetail(item.id)">
				<view style="display: flex;">
					<image :src="getImageUrl(item.img)"></image>
					<view class="service_type">{{item.type==0? "权益":"推荐"}}</view>
				</view>
				<view class="service_title">{{item.title}}</view>
				<view class="service_date">{{item.atime}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"service-list",
		data() {
			return {
				param:{},
				serviceList:[]
			};
		},
		mounted(){
			this.getServiceList()
		},
		methods:{
			getServiceList(){
				this.param.token = uni.getStorageSync("token");
				this.param.top = "1";
				this.http.get({
					url:'/index.php/Wxapp/Bussniss/getList',
					data:this.param
				}).then(resp=>{
					this.serviceList = resp.bussnissList;
					console.log("服务推荐：",resp.bussnissList)
				}).catch(err=>{
					console.log("请求服务列表失败：",err)
				})
			},
			getImageUrl(src){
				return this.domain + src;
			},
			toDetail(id){
				console.log("来了")
				uni.navigateTo({
					url:"/pages/index/services/detail/detail?id=" + id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		height: 100%;
	};
	
	.service_list {
		display: flex; //一行显示
		flex-wrap: wrap;
		justify-content: space-between;
		.service_item {
			background-color: #FFFFFF;
			height: 300rpx;
			width: 48vw;
			border-radius: 10rpx;
			.service_type {
				background-color: #1890ff;
				width: 80rpx;
				height: 50rpx;
				padding: 3rpx 10rpx;
				color: #FFFFFF;
				margin-top: 5rpx;
				margin-left: -360rpx;
				border-radius: 8rpx;
			};
			image{
				height: 200rpx;
			};
			.service_title {
				text-overflow: ellipsis;
				overflow: hidden;
				white-space: nowrap;
				justify-content: center;
				font-size: 30rpx;
				margin: 5rpx 0;
			};
			.service_date {
				margin: 5rpx 0;
				color: #999999;
			}
		}
	}
</style>
